<?php
			require_once("../../includes/user.php");
			$user=new User(); 
?>
<table width="100%" height="101" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="329" height="19" align="right" valign="middle">Select Role :</td>
    <td width="10">&nbsp;</td>
    <td width="391">
    <select name="select_role" class="FormTextFeild" id="select_role">
     <?php
			$role_res=$user->query("select * from user_role where visibility=1");
			while($role_row=mysql_fetch_array($role_res))
			{
			?>
      <option value="<?php echo $role_row['role_id']; ?>"><?php echo $role_row['role_name']; ?></option>
      <?php 
			}
			?>
    </select></td>
  </tr>
  <tr id="select_year">
    <td height="22" align="right" valign="middle">Select Year :</td>
    <td>&nbsp;</td>
    <td><select name="year" class="FormTextFeild" id="year" >
     <?php
			$year_res=$user->query("select * from year_details where visibility=1");
			while($year_row=mysql_fetch_array($year_res))
			{
			?>
      <option value="<?php echo $year_row['year_id']; ?>"><?php echo $year_row['year_name']; ?></option>
      <?php 
			}
			?>
          </select>    </td>
  </tr>
  <tr>
    <td height="22" align="right" valign="middle">Select <span id="user_role_change">Student</span> :</td>
    <td>&nbsp;</td>
    <td><select name="select_user" id="select_user" class="FormTextFeild">
      </select>    </td>
  </tr>
  <tr>
    <td height="19" colspan="3" align="center" valign="middle">&nbsp;</td>
  </tr>
  <tr>
    <td height="19" colspan="3" align="center" valign="middle"><div id="user_load"></div></td>
  </tr>
</table>
<script>
giveUser();
	$('#select_role').change(function(){
		if($('#select_role').val()==1)
		{
			$('#select_year').show();
			$('#user_role_change').html('Student');
			giveUser();
		}
		else if($('#select_role').val()==2)
		{
			$('#select_year').hide();
			$('#user_role_change').html('Staff');
			giveUser();
		}
		$('#user_load').html('');
	});
	$('#year').change(function(){
		giveUser();
		$('#user_load').html('');
	});
	$('#select_user').change(function(){
		$('#user_load').html('');
		$.post("settings/block/giveblockdetail.php",{userid:$('#select_user').val()},function(data){
				$('#user_load').html(data);
			});
	});
	function giveUser()
	{
		$.post("settings/block/giveblockdetail.php",{role:$('#select_role').val(),year:$('#year').val()},function(data){
				$('#select_user').html('<option value="0">Select User</option>'+data);
			});
	}
</script>
